package com.mhys.crm.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mhys.crm.dao.TbPatientMapper;
import com.mhys.crm.entity.TbPatient;

public class HospitalService {
	@Resource
	private TbPatientMapper tbPatientMapper;

	@RequestMapping("/select")
	public String getList(Model model) {
		List<TbPatient> selctAll = tbPatientMapper.selectAlls();
		System.out.println(selctAll);
		model.addAttribute("selctAll", selctAll);
		return "info";
	}

	@RequestMapping("/list")
	public String getAll(Model model, String name, String type, String dep) {
		List<TbPatient> selctAll = tbPatientMapper.selectAll(name, type, dep);
		System.out.println(name+"==="+type+"==="+dep);
		model.addAttribute("selctAll", selctAll);
		return "info";
	}

	@RequestMapping("/upd")
	public String upDev(Model model,int id) {
		int update = tbPatientMapper.update(id);
		return "redirect:/select.do";
	}
	
	@RequestMapping("/adds")
	public String adds(Model model) {
		return "addInfo";
	}
	
	@RequestMapping("/insert")
	public String toaddDev(Model model,TbPatient tb) {
		tbPatientMapper.insert(tb);
	    return "redirect:/select.do";
	}
}
